package com.guangfeng.yql.comm.netty.enumerate;

import java.util.Optional;

/**
 * @author yql
 * netty 信息类型
 */
public enum NettyMessageType {

    chatRoot(0, "直播间");

    public final Integer code;
    public final String message;

    NettyMessageType(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public  static NettyMessageType getEnum(Integer code){
        Optional.ofNullable(code).orElseThrow(()-> new NullPointerException("code is null"));
        NettyMessageType[] types = values();
        for (NettyMessageType socketMessageType : types) {
            if (socketMessageType.code.equals(code)){
                return  socketMessageType;
            }
        }
        return null;
    }
}
